package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TLPic;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TLPicDao;
import com.ruipengkj.service.TLPicService;
@Service
public class TLPicServiceImpl implements TLPicService {

	@Resource
	private TLPicDao TLPicDao;
	//查询所有
	@Override
	public List<TLPic> findService(TLPic entity) throws Exception {
		String hql = "select o from TLPic o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TLPicDao.findDao(hql, whereHQL.toString(), param, orderby);
	}
	//根据ID翻页查询
	@Override
	public PageModel<TLPic> getScrollService(int firstResult,
			int maxResult, TLPic entity) throws Exception {
		String hql = "select o from TLPic o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TLPicDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}

	//修改
	@Override
	public void modifyService(TLPic entity) throws Exception {
		TLPicDao.modifyDao(entity);	
	}
	//添加
	@Override
	public void saveService(TLPic entity) throws Exception {
		TLPicDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		TLPicDao.deleteDao(id);
		
	}
	//根据ID查询
	@Override
	public TLPic getByIdService(String id) throws Exception {
		return TLPicDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TLPic entity) throws Exception {
		TLPicDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TLPic entity) throws Exception {
		return TLPicDao.saveRetDao(entity);
	}
	public TLPicDao getTLPicDao() {
		return TLPicDao;
	}
	public void setTLPicDao(TLPicDao tLPicDao) {
		TLPicDao = tLPicDao;
	}
	
}
